// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   contact_draft_ok.java

package draft.logistics;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataTag;

public class contact_draft_ok extends HttpServlet
{

	public contact_draft_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			nseer_db_backup1 logistics_db = new nseer_db_backup1(dbApplication);
			if (logistics_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				ValidataTag vt = new ValidataTag();
				String contact_ID = request.getParameter("contact_ID");
				String reason = request.getParameter("reason");
				String reasonexact = request.getParameter("reasonexact");
				String provider_ID = request.getParameter("provider_ID");
				String person_contacted = request.getParameter("person_contacted");
				String person_contacted_tel = request.getParameter("person_contacted_tel");
				String contact_person = request.getParameter("contact_person");
				String contact_person_ID = request.getParameter("contact_person_ID");
				String contact_time = request.getParameter("contact_time");
				String contact_type = request.getParameter("contact_type");
				String contact_content = new String(request.getParameter("contact_content").getBytes("UTF-8"), "UTF-8");
				if (vt.validata((String)dbSession.getAttribute("unit_db_name"), "logistics_contact", "contact_ID", contact_ID, "check_tag").equals("5") || vt.validata((String)dbSession.getAttribute("unit_db_name"), "logistics_contact", "contact_ID", contact_ID, "check_tag").equals("9"))
				{
					String sql = (new StringBuilder("update logistics_contact set contact_ID='")).append(contact_ID).append("',reason='").append(reason).append("',reasonexact='").append(reasonexact).append("',provider_ID='").append(provider_ID).append("',person_contacted='").append(person_contacted).append("',person_contacted_tel='").append(person_contacted_tel).append("',contact_person='").append(contact_person).append("',contact_person_ID='").append(contact_person_ID).append("',contact_time='").append(contact_time).append("',contact_type='").append(contact_type).append("',contact_content='").append(contact_content).append("' where contact_ID='").append(contact_ID).append("'").toString();
					logistics_db.executeUpdate(sql);
					int contact_amount = 0;
					String sql3 = (new StringBuilder("select contact_amount from logistics_file where provider_ID='")).append(provider_ID).append("'").toString();
					ResultSet rs3 = logistics_db.executeQuery(sql3);
					if (rs3.next())
						contact_amount = rs3.getInt("contact_amount") + 1;
					String sql4 = (new StringBuilder("update logistics_file set contact_amount='")).append(contact_amount).append("',lately_contact_time='").append(contact_time).append("',remind_contact_tag='0' where provider_ID='").append(provider_ID).append("'").toString();
					logistics_db.executeUpdate(sql4);
					response.sendRedirect("draft/logistics/contact_ok.jsp?finished_tag=0");
				} else
				{
					response.sendRedirect("draft/logistics/contact_ok.jsp?finished_tag=1");
				}
				logistics_db.commit();
				logistics_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
